package com.bohua.Car.admin.service.Impl;

import com.bohua.Car.admin.common.Lay;
import com.bohua.Car.admin.common.Msg;
import com.bohua.Car.admin.dao.UsersMapper;
import com.bohua.Car.admin.entity.Carlook;
import com.bohua.Car.admin.entity.Users;
import com.bohua.Car.admin.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UsersMapper usersMapper;

    @Override
    public Msg addUser(Users users) {
        return null;
    }

    @Override
    public Msg update(Users users) {
        return null;
    }

    @Override
    public Msg del(Users users) {
        return null;
    }

    @Override
    public Lay getUser(Users users, Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Users> url=usersMapper.getUser(users);
        PageInfo info=new PageInfo(url);
        Lay lay = new Lay();
        lay.setPage(page);
        lay.setCount(info.getTotal());
        lay.setData(info.getList());
        lay.setLimit(limit);
        return lay;
    }

    @Override
    public Msg login(Users users) {
        Msg msg=new Msg();
        Users users1=usersMapper.login(users);
        if (users1!=null){
            msg.setData(users1);
            msg.setMsg("登陆成功");
            msg.setCode(0);
        }else {
            msg.setMsg("账号或者密码错误");
            msg.setCode(-1);
        }
        return msg;
    }


}
